<template>
	<view>
		<view class="textarea-box">
			<textarea @input="inp" :value="content" maxlength="150" style="font-size: 28rpx;width: 690rpx;" placeholder="感谢您对校园洗衣的支持，我们期待您的宝贵意见，请 点击输入...">
				
			</textarea>
			<view style="text-align: right;font-size: 24rpx;color: #CBCBCB;">{{number}}/150</view>
		</view>
		
		<view class="inp-box">
			<input style="font-size: 28rpx;" v-model="info" placeholder="请输入您的手机号或邮箱（选填）" />
		</view>
		
		<view style="display: flex;align-items: center;justify-content: center;padding-top: 43rpx;">
			<view class="send-box" @click="submit">
				提交
			</view>
		</view>
		
		<view style="display: flex;justify-content: center;align-items: center;padding-top: 30rpx;font-size: 24rpx;">
			<text style="color: #656565;">如有疑问，可直接拨打客服热线</text>
			<text style="color: #FA754F;padding-left: 10rpx;">{{kefu_mobile}}</text>
		</view>
		
	</view>
</template>

<script>
	export default{
		data(){
			return{
				number:0,
				content: '',
				info: '',
				kefu_mobile: '',
				check:0
			}
		},
		onLoad() {
			let loginstatus = uni.getStorageSync('token');
			if(loginstatus)
			{
				this.check = 1
			}
			this.getkefu()
		},
		methods:{
			inp(e){
				console.log(e)
				this.number = e.detail.cursor
				this.content = e.detail.value
			},
			// 客服热线
			getkefu() {
				this.$ajaxRequest.get(this.baseUrl + 'shop/index/customer', {}, false).then(res => {
					if (res.data.code == 200) {
						this.kefu_mobile = res.data.data.customer_tel
					} else {
						uni.showToast({
							title:res.data.msg,
							icon: 'none'
						})
					}
				})
			},
			submit() {
				if(this.check)
				{
					if (this.content == '') {
						uni.showToast({
							title:'内容不能为空',
							icon:'none'
						})
					} else {
						this.$ajaxRequest.post(this.baseUrl + 'shop/opinion/info', {
							content: this.content,
							info: this.info
						}, true).then(res => {
							console.log(res)
							if (res.data.code == 200) {
								uni.showToast({
									title:res.data.msg,
									icon: 'none'
								})
								setTimeout(() => {
									uni.navigateBack({
										delta:1
									})
								}, 500)
							} else {
								uni.showToast({
									title:res.data.msg,
									icon: 'none'
								})
							}
						})
					}
				}else{
					uni.showToast({
						title:'请先登录',
						icon:'error'
					})
				}
				
			}
		}
	}
</script>

<style>
	.textarea-box{
		border-top: 20rpx solid #F5F5F5;
		padding: 30rpx;
	}
	.inp-box{
		border-top: 20rpx solid #F5F5F5;
		padding: 30rpx;
		border-bottom: 1rpx solid #F5F5F5;
	}
	.send-box{
		width:600rpx;
		height:90rpx;
		background:rgba(255,121,59,1);
		border-radius:44rpx;
		text-align: center;
		line-height: 90rpx;
		color: white;
		font-size: 34rpx;
	}
</style>
